/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gov.mtc.dgac.licencias.service;

import java.util.HashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import pe.gov.mtc.dgac.licencias.bean.ClienteTO;
import pe.gov.mtc.dgac.licencias.exception.BusinessException;
import pe.gov.mtc.dgac.licencias.persistence.ClienteDAO;
import pe.gov.mtc.dgac.licencias.struts.Constants;
import pe.gov.mtc.dgac.licencias.util.Page;

/**
 *
 * @author externo.gamaro
 */
public class ClienteImplService implements ClienteService {
   private ClienteDAO dao;
     Log logger = LogFactory.getLog(this.getClass());
    public ClienteImplService(ClienteDAO dao){
      this.dao=dao;
    }
    public List<ClienteTO> buscarCliente(ClienteTO cliente) throws BusinessException {
        List<ClienteTO> result=null;
        try{
             result=dao.buscarCliente(cliente);
        }catch(Exception e){
          logger.error(e);
	  throw new BusinessException(Constants.MESSAGE_ERROR_CLIENTE_CONSULTA.getValue(),e);
        }
        
        return result;
    }

    public Page buscarCliente(ClienteTO cliente, int page, int pageSize) throws BusinessException {
        Page result=null;
        try{
             result=dao.buscarCliente(cliente, page, pageSize);
        }catch(Exception e){
          logger.error(e);
	  throw new BusinessException(Constants.MESSAGE_ERROR_CLIENTE_CONSULTA.getValue(),e);
        }
        
        return result;
    }

    public HashMap insertCliente(ClienteTO cliente) throws BusinessException {
       HashMap result=null;
        try{
             result=dao.insertCliente(cliente);
        }catch(Exception e){
          logger.error(e);
	  throw new BusinessException(Constants.MESSAGE_ERROR_CLIENTE_UPDATE.getValue(),e);
        }
        
        return result;
    }
    
    public HashMap updateCliente(ClienteTO cliente) throws BusinessException {
       HashMap result=null;
        try{
             result=dao.updateCliente(cliente);
        }catch(Exception e){
          logger.error(e);
	  throw new BusinessException(Constants.MESSAGE_ERROR_CLIENTE_UPDATE.getValue(),e);
        }
        
        return result;
    }
}
